#ifndef _CP_TOKEN_MESSAGE_HPP
#define _CP_TOKEN_MESSAGE_HPP

#include <boost/shared_ptr.hpp>
#include "MacArrayMessage.hpp"

namespace BFT
{
	namespace messages
	{
		class CPTokenMessage : public MacArrayMessage
		{
			public:
			
			CPTokenMessage( boost::shared_ptr<char> _tok, int _tok_size, uint32_t _seq, uint32_t _sender);

			CPTokenMessage( boost::shared_ptr<char> _bytes, int  _bytes_size);
			
			uint32_t getSendingReplica();
			
			boost::shared_ptr<char> getToken(int& _token_size);
			
			uint32_t getSequenceNumber();
			
			bool equals(boost::shared_ptr<CPTokenMessage> _other_cpt);

			bool matches(boost::shared_ptr<CPTokenMessage> _other_cpt);
			
			void printInfo();
			
			protected:
			
			boost::shared_ptr<char> token;
			int token_size;
			uint32_t seqNo;
			
			private:
			
			static uint32_t computeSize(int _token_size);
		};
		
		inline uint32_t CPTokenMessage::getSendingReplica() {return getSender();}
		inline uint32_t CPTokenMessage::getSequenceNumber() {return seqNo;}
		inline uint32_t CPTokenMessage::computeSize(int _token_size) {return _token_size + SEQUENCE_NUMBER_SIZE + TOKEN_SIZE_SIZE;}
		
	}
}

#endif
